package com.lebo.portal.view;

import java.io.Serializable;

public class PageInfo implements Serializable, Cloneable {
    private static final long serialVersionUID = -7269270519159881487L;

    /**
     * @field 当前页
     */
    private Integer currPage = 0;

    /**
     * @field 每页条数
     */
    private Integer pageSize = 20;

    /**
     * @field 总页数
     */
    private Integer totalPage;

    /**
     * @field 总记录数
     */
    private Long totalItem;

    public Integer getCurrPage() {
        return currPage;
    }

    public void setCurrPage(Integer currPage) {
        this.currPage = currPage;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public Long getTotalItem() {
        return totalItem;
    }

    public void setTotalItem(Long totalItem) {
        this.totalItem = totalItem;
    }

    @Override
    protected PageInfo clone() throws CloneNotSupportedException {
        PageInfo page = new PageInfo();
        if(null != this.currPage) {
            page.setCurrPage(this.currPage);
        }
        if(null != this.totalItem) {
            page.setTotalItem(this.totalItem);
        }
        if(null != this.pageSize) {
            page.setPageSize(this.pageSize);
        }
        if(null != this.totalPage) {
            page.setTotalPage(this.totalPage);
        }
        return page;
    }

    public PageInfo initializeToZero() {
        this.currPage = 0;
        this.totalItem = 0L;
        this.pageSize = 0;
        this.totalPage = 0;
        return this;
    }

    public PageInfo clonePageInfo() {
        try {
            return this.clone();
        } catch (CloneNotSupportedException e) {
            return this.initializeToZero();
        }
    }
}

